import { getHttp } from './http'
// 首页游戏列表
export const gameListApi = async () => {
    const http = getHttp()
    const res = await http('/lobby/user/gameList', {
        method: 'GET',
    })
    if (res.code === 0) {
        return res.data
    } else {
        showFailToast(res.message);
    }
}
export const gameSubItemApi = async (gameType: number) => {
    const http = getHttp()
    const res = await http(`/lobby/user/gameSubItemList/${gameType}`, {
        method: 'GET',
    })
    if (res.code === 0) {
        return res.data
    } else {
        showFailToast(res.message);
    }
}
// 收藏
export const saveCollectApi = async (data: { gameId: number, add: boolean }) => {
    const http = getHttp()
    const res = await http('/lobby/user/saveCollect', {
        method: 'POST',
        body: data,
    })
    if (res.code === 0) {
        return res.data
    } else {
        showFailToast(res.message);
    }
}
// 收藏
export const gameUrlApi = async (data: { gameId: number; uid?: number }) => {
    const http = getHttp()
    const res = await http('/lobby/user/getGameUrl', {
        method: 'POST',
        body: data,
    })
    if (res.code === 0) {
        return res.data
    } else {
        showFailToast(res.message);
    }
}